<div id="Removing-files"></div>
<div class="header">
<p>
Next: [[cvs: Removing directories#Removing directories|Removing directories]], Previous: [[cvs: Adding files to a directory#Adding files to a directory|Adding files]], Up: [[cvs: Adding, removing, and renaming files and directories#Adding, removing, and renaming files and directories|Adding and removing]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>

----

<div id="Removing-files-1"></div>
=== Removing files ===
<div id="index-Removing-files"></div>
<div id="index-Deleting-files"></div>

Directories change.  New files are added, and old files
disappear.  Still, you want to be able to retrieve an
exact copy of old releases.

Here is what you can do to remove a file,
but remain able to retrieve old revisions:


* Make sure that you have not made any uncommitted modifications to the file.  See [[cvs: Viewing differences#Viewing differences|Viewing differences]], for one way to do that.  You can also use the <code>status</code> or <code>update</code> command.  If you remove the file without committing your changes, you will of course not be able to retrieve the file as it was immediately before you deleted it.


* Remove the file from your working copy of the directory. You can for instance use <code>rm</code>.


* Use &lsquo;<code>cvs remove <var>filename</var></code>&rsquo; to tell <small>CVS</small> that you really want to delete the file.


* Use &lsquo;<code>cvs commit <var>filename</var></code>&rsquo; to actually perform the removal of the file from the repository.

When you commit the removal of the file, <small>CVS</small>
records the fact that the file no longer exists.  It is
possible for a file to exist on only some branches and
not on others, or to re-add another file with the same
name later.  <small>CVS</small> will correctly create or not create
the file, based on the &lsquo;<code>-r</code>&rsquo; and &lsquo;<code>-D</code>&rsquo; options
specified to <code>checkout</code> or <code>update</code>.

<div id="index-Remove-_0028subcommand_0029"></div>
;<div id="index-cvs-remove"></div>Command<nowiki>:</nowiki> <strong>cvs remove</strong><em> <nowiki>[</nowiki>options<nowiki>]</nowiki> files &hellip;</em>

: Schedule file(s) to be removed from the repository (files which have not already been removed from the working directory are not processed).  This command does not actually remove the file from the repository until you commit the removal.  For a full list of options, see [[cvs: Quick reference to CVS commands#Quick reference to CVS commands|Invoking CVS]].

Here is an example of removing several files:

<div class="example" style="margin-left: 3.2em">
 $ cd test
 $ rm *.c
 $ cvs remove
 cvs remove: Removing .
 cvs remove: scheduling a.c for removal
 cvs remove: scheduling b.c for removal
 cvs remove: use 'cvs commit' to remove these files permanently
 $ cvs ci -m &quot;Removed unneeded files&quot;
 cvs commit: Examining .
 cvs commit: Committing .
</div>

As a convenience you can remove the file and <code>cvs
remove</code> it in one step, by specifying the &lsquo;<code>-f</code>&rsquo;
option.  For example, the above example could also be
done like this:

<div class="example" style="margin-left: 3.2em">
 $ cd test
 $ cvs remove -f *.c
 cvs remove: scheduling a.c for removal
 cvs remove: scheduling b.c for removal
 cvs remove: use 'cvs commit' to remove these files permanently
 $ cvs ci -m &quot;Removed unneeded files&quot;
 cvs commit: Examining .
 cvs commit: Committing .
</div>

If you execute <code>remove</code> for a file, and then
change your mind before you commit, you can undo the
<code>remove</code> with an <code>add</code> command.


<div class="example" style="margin-left: 3.2em">
 $ ls
 CVS   ja.h  oj.c
 $ rm oj.c
 $ cvs remove oj.c
 cvs remove: scheduling oj.c for removal
 cvs remove: use 'cvs commit' to remove this file permanently
 $ cvs add oj.c
 U oj.c
 cvs add: oj.c, version 1.1.1.1, resurrected
</div>

If you realize your mistake before you run the
<code>remove</code> command you can use <code>update</code> to
resurrect the file:

<div class="example" style="margin-left: 3.2em">
 $ rm oj.c
 $ cvs update oj.c
 cvs update: warning: oj.c was lost
 U oj.c
</div>

When you remove a file it is removed only on the branch
which you are working on (see [[cvs: Branching and merging#Branching and merging|Branching and merging]]).  You can
later merge the removals to another branch if you want
(see [[cvs: Merging can add or remove files#Merging can add or remove files|Merging adds and removals]]).


----

<div class="header">
<p>
Next: [[cvs: Removing directories#Removing directories|Removing directories]], Previous: [[cvs: Adding files to a directory#Adding files to a directory|Adding files]], Up: [[cvs: Adding, removing, and renaming files and directories#Adding, removing, and renaming files and directories|Adding and removing]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>
This document was generated on <i>a sunny day</i> using [http://www.nongnu.org/texi2html/ <i>texi2html</i>].
